package com.dc.common.core;

import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * @author zhuangcy
 * @date 2021/1/19
 * @description 自定义token
 */
public class MyToken extends UsernamePasswordToken {

    private String token;
    private LoginBody loginBody;
    private String loginType;

    public MyToken(String token, LoginBody loginBody) {
        this.token = token;
        this.loginBody = loginBody;
    }

    public MyToken(String token, String loginType, LoginBody loginBody) {
        this.token = token;
        this.loginType = loginType;
        this.loginBody = loginBody;
    }

    public String getToken() {
        return token;
    }

    public LoginBody getLoginBody() {
        return loginBody;
    }

    public String getLoginType() {
        return loginType;
    }

    /**
     * 获取登录用户
     *
     * @return
     */
    @Override
    public Object getPrincipal() {
        return this.loginBody;
    }

    /**
     * 获取凭证
     *
     * @return
     */
    @Override
    public Object getCredentials() {
        return this.token;
    }
}